//
// Decompiled by Jadx - 593ms
//
package gc;

import a.g;
import a.i;
import de.robv.android.xposed.XposedHelpers;
import fm.j;
import fn.b;
import fn.x;
import fn.y;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Pattern;
import me.plusne.Adapter.Login.h;
import me.plusne.GreenDao.dao.SoulAutoLogDao;
import me.plusne.NativeTools;
import me.plusne.common.Json.JsonHookStatic;
import me.plusne.common.Json.Soul.JsonAutoLog;
import me.plusne.common.Json.Soul.JsonSoulAutoMessage;
import o.a;
import r.f;

@a("SOUL")
public final class at extends x {
    public static JsonSoulAutoMessage cp;
    public String cq;

    public static void cr(Object obj) {
        long longField = XposedHelpers.getLongField(obj, "id");
        if (cu(1, longField) && ct(obj, y.ch("autoLikeCheck", false), y.cb("autoLikeProbability"), y.cd(0, "autoLikeTime"), y.cd(-1, "autoLikeType"))) {
            cv(obj, y.cd(0, "autoLikeSex"), y.cd(0, "autoLikeNum"), y.cd(0, "autoLikeRegDay"), new h(26));
        }
        if (cu(2, longField) && ct(obj, y.ch("autoFollowCheck", false), y.cb("autoFollowProbability"), y.cd(0, "autoFollowTime"), y.cd(-1, "autoFollowType"))) {
            cv(obj, y.cd(0, "autoFollowSex"), y.cd(0, "autoFollowNum"), y.cd(0, "autoFollowRegDay"), new h(27));
        }
        if (cu(3, longField) && ct(obj, y.ch("autoReplyCheck", false), y.cb("autoReplyProbability"), y.cd(0, "autoReplyTime"), y.cd(-1, "autoReplyType"))) {
            cv(obj, y.cd(0, "autoReplySex"), y.cd(0, "autoReplyNum"), y.cd(0, "autoReplyRegDay"), new h(28));
        }
        boolean cu = cu(4, longField);
        JsonHookStatic jsonHookStatic = y.by;
        if (cu && NativeTools.n(JsonHookStatic.l, jsonHookStatic.getUserInfo()) && ct(obj, y.ch("autoGiftCheck", false), y.cb("autoGiftProbability"), y.cd(0, "autoGiftTime"), y.cd(-1, "autoGiftType"))) {
            cv(obj, y.cd(0, "autoGiftSex"), y.cd(0, "autoGiftNum"), y.cd(0, "autoGiftRegDay"), new h(29));
        }
        if (cu(5, longField) && NativeTools.n(JsonHookStatic.l, jsonHookStatic.getUserInfo()) && ct(obj, y.ch("autoBgImgCheck", false), y.cb("autoBgImgProbability"), y.cd(0, "autoBgImgTime"), y.cd(-1, "autoBgImgType"))) {
            cv(obj, y.cd(0, "autoBgImgSex"), y.cd(0, "autoBgImgNum"), y.cd(0, "autoBgImgRegDay"), new aq(0));
        }
        if (cu(6, longField) && NativeTools.n(JsonHookStatic.l, jsonHookStatic.getUserInfo()) && ct(obj, y.ch("autoInvitePostCheck", false), y.cb("autoInvitePostProbability"), y.cd(0, "autoInvitePostTime"), y.cd(-1, "autoInvitePostType"))) {
            cv(obj, y.cd(0, "autoInvitePostSex"), y.cd(0, "autoInvitePostNum"), y.cd(0, "autoInvitePostRegDay"), new aq(1));
        }
        if (cu(7, longField) && NativeTools.n(JsonHookStatic.l, jsonHookStatic.getUserInfo()) && ct(obj, y.ch("autoReCallNewsCheck", false), y.cb("autoReCallNewsProbability"), y.cd(0, "autoReCallNewsTime"), y.cd(-1, "autoReCallNewsType"))) {
            cv(obj, y.cd(0, "autoReCallNewsSex"), y.cd(0, "autoReCallNewsNum"), y.cd(0, "autoReCallNewsRegDay"), new aq(2));
        }
        if (cu(8, longField) && NativeTools.n(JsonHookStatic.l, jsonHookStatic.getUserInfo()) && ct(obj, y.ch("autoLoveSpeedCheck", false), y.cb("autoLoveSpeedProbability"), y.cd(0, "autoLoveSpeedTime"), y.cd(-1, "autoLoveSpeedType"))) {
            cv(obj, y.cd(0, "autoLoveSpeedSex"), y.cd(0, "autoLoveSpeedNum"), y.cd(0, "autoLoveSpeedRegDay"), new aq(3));
        }
    }

    public static void cs(int i, long j) {
        JsonHookStatic jsonHookStatic = y.by;
        SoulAutoLogDao soulAutoLogDao = jsonHookStatic.getDb().w;
        soulAutoLogDao.getClass();
        g gVar = new g(soulAutoLogDao);
        gVar.l(SoulAutoLogDao.Properties.PostId.f(Long.valueOf(j)), new i[]{SoulAutoLogDao.Properties.Type.f(Integer.valueOf(i))});
        gVar.i(1);
        j jVar = (j) gVar.k();
        if (jVar == null) {
            j jVar2 = new j();
            jVar2.b = j;
            jVar2.c = i;
            jsonHookStatic.getDb().j(jVar2);
            return;
        }
        jVar.b = j;
        jVar.c = i;
        jsonHookStatic.getDb().l(jVar);
    }

    public static boolean ct(Object obj, boolean z, double d, int i, int i2) {
        boolean z2;
        if (obj == null || !z) {
            return false;
        }
        if (d < 1.0d) {
            if (new Random(ThreadLocalRandom.current().nextLong()).nextDouble() * 100.0d < d) {
                z2 = true;
            } else {
                z2 = false;
            }
            if (!z2) {
                return false;
            }
        }
        if (i > 0) {
            long longField = XposedHelpers.getLongField(obj, "createTime");
            if (longField < 0 || (i * 1000 * 60) + longField < System.currentTimeMillis()) {
                return false;
            }
        }
        if (i2 != -1 && ((Enum) XposedHelpers.getObjectField(obj, "type")).ordinal() != i2) {
            return false;
        }
        return true;
    }

    public static boolean cu(int i, long j) {
        SoulAutoLogDao soulAutoLogDao = y.by.getDb().w;
        soulAutoLogDao.getClass();
        g gVar = new g(soulAutoLogDao);
        gVar.l(SoulAutoLogDao.Properties.PostId.f(Long.valueOf(j)), new i[]{SoulAutoLogDao.Properties.Type.f(Integer.valueOf(i))});
        gVar.i(1);
        if (gVar.k() == null) {
            return true;
        }
        return false;
    }

    public static void cv(Object obj, int i, int i2, int i3, b bVar) {
        String as = fn.j.as(obj, "authorIdEcpt");
        if (Pattern.compile("[0-9]*").matcher(as).matches()) {
            as = z.do(as);
        }
        fm.i e = b.e(2003, as);
        if (e == null) {
            ac acVar = new ac();
            acVar.dd("https://api-user.soulapp.cn/users/info?userIds=" + fn.j.as(obj, "authorIdEcpt"));
            acVar.dg(new as(obj, i, i2, i3, bVar));
            return;
        }
        cw(obj, i, i2, i3, bVar, e.c);
    }

    public static void cw(Object obj, int i, int i2, int i3, b bVar, String str) {
        JsonAutoLog jsonAutoLog = (JsonAutoLog) androidx.activity.b.c(str, JsonAutoLog.class);
        boolean z = false;
        int cd = y.cd(0, "autoAge");
        if (cd > 0 && jsonAutoLog.getBirthday() > cd) {
            bVar.d(obj, false);
            return;
        }
        if (i == 2 && jsonAutoLog.getGenderelation() != 0) {
            bVar.d(obj, false);
            return;
        }
        if (i == 3 && jsonAutoLog.getGenderelation() != 1) {
            bVar.d(obj, false);
            return;
        }
        if (i2 > 0 && i2 < jsonAutoLog.getRoundCount()) {
            bVar.d(obj, false);
            return;
        }
        if (i3 == 0) {
            bVar.d(obj, true);
            return;
        }
        int registerDay = jsonAutoLog.getRegisterDay();
        if (i3 >= 0 ? registerDay >= i3 : registerDay <= (-i3)) {
            z = true;
        }
        bVar.d(obj, z);
    }

    public static void cx(String str, String str2) {
        if (b.e(15, str) != null) {
            f i = f.i();
            i.j();
            i.d = 48;
            i.l("已有发送礼物的记录");
            return;
        }
        ag.cs("cn.soulapp.android.component.chat.api.ChatAPI", "USER", "reportMessage", new f(str, 2), new Object[]{"1", z.do(str), str2, 0L});
    }

    public final void a() {
        fn.j.ba("cn.soulapp.android.component.square.main.squarepost.footer.DefaultFooter", "onBindViewHolder", new a(this));
    }
}
